
$(document).ready(function(){
	
	//更多新闻
	$("#moreNew").click(
		function(){  
        $.ajax({  
        data:"typeid="+$("#typeid").val()+"&page="+$("#page").val(),  
        type:"post",  
        dataType: 'json',  
        url:"<%= path%>/more_news",  
        error:function(data){  
            alert("no more！");  
        },  
        success:function(data){  
        	var nextpage="";
    		var datalist="";
    		var newhtml="";
    		$.each(data,function(key,values){ 
        	    $(values).each(function(){ 
        	    	if(key=='nextpage'){
        	    		nextpage=this; 
        	    		$("#page").val(nextpage);
        	    	}
        	    	if (key=='data') {
        	    		datalist=this;
        			newhtml+=(" <li class=\"list-group-item\">"+"<a target=\"_blank\" href=<%= path%>/new-detail/\""+datalist.id+"\">"+datalist.title +"</a><br/></li>");
					}
        	    });  
        	  });  
    		if (newhtml.length<10) {
       		 $("#list2").append(" <li class=\"list-group-item\" style=\"text-align: center;\">"+"没有更多了！！！"+"</li>");
		        $("p").hide();
			}else{
       		 $("#list2").append(newhtml+"<br>");
		        $("p").hide();
			}
        }
        
        }); 
        
    });  });
			//weather 
			/*$.ajax({  
			    type:"post",  
			    dataType: 'json',  
			    url:"<%= path%>/tianqi",  
			    error:function(data){  
			        alert(data.errMsg);  
			    },  
			    success:function(data){  
			    		var dd=data.data[0];
			    		if (dd.status=='ok') {
			    			$("#tq").append(dd.basic.city+'  '+dd.now.cond.txt+'  '+dd.now.tmp+'℃ '+'  '+dd.now.wind.dir+'  '+dd.now.wind.sc+'级'+' '+'空气质量：'+dd.aqi.city.qlty+' '+'pm2.5：'+dd.aqi.city.pm25+'</br>');
						}else{
							$("#tq").append(data.errMsg);
						}
			    }
			    
			    });*/
			  
			
			/* 当滚动条滚动到页面底部自动加载 */
		/*	window.onscroll = function () { 
			if (getScrollTop() + getClientHeight() == getScrollHeight()) { 
		        $.ajax({  
		            data:"typeid="+$("#typeid").val()+"&page="+$("#page").val(),  
		            type:"post",  
		            dataType: 'json',  
		            url:"<%= path%>/more_news",  
		            error:function(data){  
		                alert("没有更多新闻了！");  
		            },  
		            success:function(data){  
		            	var nextpage="";
		        		var datalist="";
		        		var newhtml="";
		        		$.each(data,function(key,values){ 
		            	    $(values).each(function(){ 
		            	    	if(key=='nextpage'){
		            	    		nextpage=this; 
		            	    		$("#page").val(nextpage);
		            	    	}
		            	    	if (key=='data') {
		            	    		datalist=this;
		            			newhtml+=(" <li class=\"list-group-item\">"+"<a target=\"_blank\" href=<%= path%>/new-detail/\""
																						+ datalist.id
																						+ "\">"
																						+ datalist.title + "</a><br/></li>");
																			}
																		});
													});
									if (newhtml.length < 10) {
										$("p").hide();
									} else {
										$("#list2").append(newhtml + "<br>");
										$("p").hide();
									}
								}
							});
				}
			}*/




//获取滚动条当前的位置 
function getScrollTop() { 
var scrollTop = 0; 
if (document.documentElement && document.documentElement.scrollTop) { 
scrollTop = document.documentElement.scrollTop; 
} 
else if (document.body) { 
scrollTop = document.body.scrollTop; 
} 
return scrollTop; 
} 

//获取当前可是范围的高度 
function getClientHeight() { 
var clientHeight = 0; 
if (document.body.clientHeight && document.documentElement.clientHeight) { 
clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight); 
} 
else { 
clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight); 
} 
return clientHeight; 
} 

//获取文档完整的高度 
function getScrollHeight() { 
return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); 
} 